<?php
/**
 * 权限
 */
namespace app\model;

use think\Model;
use app\libs\Predis;

class IndustryModel extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $name = 'industry';
    
    // 设置字段信息
    protected $schema111 = [
        'id'          => 'int',
        'industry_name'        => 'string',
    ];
    
    // 设置当前模型的数据库连接
    protected $connection ='db_yunduan';
   
   /**
    * 递归
    */
    public function GetInfo($id=0){

        $cache = new Predis();
        $data=$cache->get('IndustryDiGui_'.$id);
        if($data){
            $result=unserialize($data);
        }else{
            $industry = new IndustryModel();
            $res=$industry->field('id,industry_name,pid')->where(['status'=>1])->select()->toArray();
    
            $result=arr2tree($res,$id,'industry_name','id');
            $cache->set('IndustryDiGui_'.$id,serialize($result),3600);
        }
        return $result;        
    }


}
 